<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="UTF-8">
		<title>购物车1</title>
		<link rel="stylesheet" type="text/css" href="../css/reset.css" />
		<link rel="stylesheet" type="text/css" href="../css/t-goshoping.css" />
		<link rel="stylesheet" type="text/css" href="../css/foot.css" />
		<link rel="stylesheet" type="text/css" href="../css/nava.css" />
		<script type="text/javascript" src="../js/angular.min.js"></script>
		<script type="text/javascript" src="../js/angular-route.min.js"></script>
		<script type="text/javascript" src="../js/jquery-3.0.0.min.js"></script>
	</head>

	<body ng-app="myApp" ng-controller='buyCtrl1'>
		<div ng-include="'nava.html'"></div>
		<div class="logo-shoping clearfix">
			<ul>
				<li>
					<img src="../img/t-logo.png" />
				</li>
				<li>
					<span class="go-span1">我的购物车</span>
					<img src="../img/t-rightguide.png" alt="" />
					<span class="go-span2">确认订单消息</span>
					<img src="../img/t-rightguide.png" alt="" />
					<span class="go-span3">订单提交成功</span>
				</li>
			</ul>
		</div>

		<div class="t-firstshop">
			<div class="tbuycar"><img src="../img/t-buycar.png" alt="" /><span>购物车</span></div>

			<ul class="t-uls1">
				<li class="clearfix">
					<div class="da" ng-click='checkall1($index)'><img class="imgall" src="../img/t-surebuy.png" alt="" /></div>

					<span>爱果果水果店</span>
					<span>规格</span>
					<span>单价</span>
					<span>数量</span>
					<span>金额</span>
					<span>操作</span>
				</li>
				<li class="clearfix" ng-repeat='item in a'>

					<div class="clearfix aaa" ng-click='check($index)'><img src="../img/t-surebuy.png" alt="" class="imgg" /></div>
					<div><img src="../img/loveapple.png" alt="" class="imga" /><span>{{item.name}}</span></div>
					<div>{{item.size}}</div>
					<div class="price1">{{item.price}}</div>
					<div><img src="../img/t-subtract.png" class="ddu" alt="" ng-click="ddfun($index)" /><input type="text" class="numinp" value="1" /><img class="uup" src="../img/t-add.png" alt="" ng-click="uufun($index)" /></div>
					<div class="onemoney">{{item.price}}</div>
					<div class="t-delete" ng-click='del($index)'>删除</div>
				</li>

				<li class="clearfix">
					<span class="t-money1">¥1705</span>
					<span>商品金额</span>

				</li>

			</ul>
			<ul class="t-uls2">
				<li class="clearfix">
					<div class="daa" ng-click='checkall2($index)'><img class="imgal2" src="../img/t-surebuy.png" alt="" /></div>
					<!--<div><img src="../img/t-surebuy.png" alt=""/></div>-->
					<span>爱果果水果店</span>
					<span>规格</span>
					<span>单价</span>
					<span>数量</span>
					<span>金额</span>
					<span>操作</span>
				</li>
				<li class="clearfix" ng-repeat='item1 in b'>

					<div class="clearfix bbb" ng-click='check1($index)'><img src="../img/t-surebuy.png" alt="" class="imgg1" /></div>
					<div><img src="../img/loveapple.png" alt="" /><span>{{item1.name}}</span></div>
					<div>{{item1.size}}</div>
					<div class="price2">{{item1.price}}</div>
					<div><img src="../img/t-subtract.png" class="ddu" alt="" ng-click="ddfun1($index)" /><input type="text" class="numinp1" value="1" /><img class="uup" src="../img/t-add.png" alt="" ng-click="uufun1($index)" /></div>
					<div class="onemoney1">{{item1.price}}</div>
					<div class="t-delete1" ng-click='dell($index)'>删除</div>
				</li>

				<li class="clearfix">
					<span class="t-money2">¥1705</span>
					<span>商品金额</span>

				</li>
				<li class="clearfix">
					<div>
						<span class="t-allSpan">全选</span>
						<span class="t-alldelete">批量删除</span>
					</div>
					<div>
						<span>商品总计：</span>
						<span class="t-allmoney">¥ 3410</span>
						<a class="t-allbuy" href="#/t-shoping2" ng-click='colorfun()'>立即购买</a>
					</div>
				</li>
			</ul>
			<div class="t-none">
				<img src="../img/t-car.png" alt="" />
				<p>您的购物车为空</p>
				<a href="index.html">去首页看看</a>
			</div>
		</div>

		<div class="t-meng">
		</div>
		<div class="t-win">
			<div>温馨提示</div>
			<div class="clearfix">
				<img src="../img/t-notice.png" alt="" />
				<h2>新疆哈密瓜（8kg装）、葡萄（150g）</h2>
				<p>无法配送到指定区域、请到购物车中删除</p>
				<p>或修改配送地址后重新提交订单</p>
			</div>
			<div>
				<span>返回购物车修改</span>
				<span>修改配送区域</span>
			</div>
		</div>
		<div class="t-win1">
			<h1>使用平台支付</h1>
			<p>请您在新打开的网上银行页面进行支付，完成支付前请不要关闭该窗口</p>
			<div>
				<div>
					<p>已经完成支付</p>
					<p>查看订单详情</p>
				</div>
				<div>
					<p>支付失败</p>
					<p>更换支付方式</p>
				</div>
			</div>
		</div>
		<div ng-include="'foot.html'"></div>
	</body>
	<script type="text/javascript" src="../js/angular-route.min.js"></script>
	<script type="text/javascript">
		var app = angular.module('myApp', ['ngRoute']);

		var bubu = false;
		var num = Number($('.numinp').val())
		app.controller('buyCtrl1', function($scope, $http) {
			var max = true;
			var bl = true;
			var length = 0;
			var length1 = 0;
			var t1 = 1705;
			var t2 = 1705;
			var buer = true;
			//			 var bure1 = true;
			var buer1 = true;
			var arrcheck1 = [];
			var arrcheck2 = [];
			var index1 = 0;
			var buer2 = true;

			$scope.check = function(index) {
				arrcheck1.push(index)
				$('.imgg').eq(index).toggle();
				//			 	alert(index)

			}
			$scope.check1 = function(index) {
				arrcheck2.push(index)
				$('.imgg1').eq(index).toggle();

			}

			$scope.checkall1 = function(index) {

				$('.imgall').toggle();
				if(buer) {
					$('.imgg').show();
					buer = false;

				} else {
					$('.imgg').hide();
					buer = true;
				}
			}

			$scope.checkall2 = function(index) {

				$('.imgal2').toggle();
				if(buer1) {
					$('.imgg1').show();
					buer1 = false;

				} else {
					$('.imgg1').hide();
					buer1 = true;
				}
			}

			$('.t-alldelete').click(function() {
				if(buer == false) {
					$('.t-uls1').remove();
				}
				if(buer1 == false) {
					$('.t-uls2').remove();

				}
			});
			$('.t-allSpan').click(function() {
				$('.imgall').toggle();
				$('.imgal2').toggle();
				if(buer2) {
					$('.imgg1').show();
					$('.imgg').show();
					$('.t-alldelete').click(function() {
						$('.t-uls1').remove();
						$('.t-uls2').remove();
						$('.t-none').show();
					})

					buer2 = false;
				} else {
					$('.imgg1').hide();
					$('.imgg').hide();
					buer2 = true;
				}
			})
			$http.get('../php/datafruit.php').success(function(data) {
				$scope.a = data;
				length = data.length;
			});
			$http.get('../php/datafruit.php').success(function(data) {
				$scope.b = data;
				length1 = data.length;
			});
			$scope.del = function(index) {
				$scope.a.splice(index, 1);
				var aa = $('.onemoney').eq(index).parent().siblings().children('.onemoney').text();
				aa = aa.split("¥");
				var kk = 0;
				for(var i = 0; i < aa.length; i++) {
					if(aa[i] == '') {
						aa.splice(i, 1)
					}
				}
				for(var i = 0; i < aa.length; i++) {
					aa[i] = Number(aa[i]);
					kk += aa[i];
				}
				t1 = kk;

				$('.t-money1').html('¥' + kk);
				$('.t-allmoney').html('¥' + (t1 + t2));
				if((t1 + t2) == 0) {
					$('.t-uls1').remove();
					$('.t-uls2').remove();
					$('.t-none').show();
				}
			};
			$scope.dell = function(index) {
				$scope.b.splice(index, 1);
				var aa = $('.onemoney1').eq(index).parent().siblings().children('.onemoney1').text();
				aa = aa.split("¥");
				var kk = 0;
				for(var i = 0; i < aa.length; i++) {
					if(aa[i] == '') {
						aa.splice(i, 1)
					}
				}
				for(var i = 0; i < aa.length; i++) {
					aa[i] = Number(aa[i]);
					kk += aa[i];
				}
				t2 = kk;

				$('.t-money2').html('¥' + kk);
				$('.t-allmoney').html('¥' + (t1 + t2));

				if((t1 + t2) == 0) {
					$('.t-uls1').remove();
					$('.t-uls2').remove();
					$('.t-none').show();
				}
			};
			$scope.ddfun = function(index) {
				var b = Number($('.numinp').eq(index).val());
				var pr1 = $('.price1').eq(index).text();
				pr1 = pr1.split("¥")[1];
				pr1 = Number(pr1);
				var arr = [];
				var ff = 0;

				if(b > 1) {
					b--;
					$('.numinp').eq(index).val(b);
					var all1 = b * pr1;
					$('.onemoney').eq(index).html('¥' + all1);
					var aa = $('.onemoney').eq(index).parent().siblings().children('.onemoney').text();
					aa = aa.split("¥");
					var kk = 0;
					for(var i = 0; i < aa.length; i++) {
						if(aa[i] == '') {
							aa.splice(i, 1)
						}
					}
					for(var i = 0; i < aa.length; i++) {
						aa[i] = Number(aa[i]);
						kk += aa[i];
					}
					t1 = all1 + kk
					$('.t-money1').html('¥' + (all1 + kk));
					$('.t-allmoney').html('¥' + (t1 + t2));
				}

			};
			$scope.ddfun1 = function(index) {
				var b = Number($('.numinp1').eq(index).val());
				var pr1 = $('.price2').eq(index).text();
				pr1 = pr1.split("¥")[1];
				pr1 = Number(pr1);
				var ff = 0;

				if(b > 1) {
					b--;
					$('.numinp1').eq(index).val(b);
					var all1 = b * pr1;
					$('.onemoney1').eq(index).html('¥' + all1);
					var aa = $('.onemoney1').eq(index).parent().siblings().children('.onemoney1').text();
					aa = aa.split("¥");
					var kk = 0;
					for(var i = 0; i < aa.length; i++) {
						if(aa[i] == '') {
							aa.splice(i, 1)
						}
					}
					for(var i = 0; i < aa.length; i++) {
						aa[i] = Number(aa[i]);
						kk += aa[i];
					}
					t2 = all1 + kk;
					$('.t-money2').html('¥' + (all1 + kk));
					$('.t-allmoney').html('¥' + (t1 + t2));
				}

			};

			$scope.uufun = function(index) {
				var gg = 0;
				var c = Number($('.numinp').eq(index).val());
				var pr2 = $('.price1').eq(index).text();
				pr2 = pr2.split("¥")[1];
				pr2 = Number(pr2);
				c++;
				$('.numinp').eq(index).val(c);
				var all2 = c * pr2;
				$('.onemoney').eq(index).html('¥' + all2);

				var aa = $('.onemoney').eq(index).parent().siblings().children('.onemoney').text();
				aa = aa.split("¥");
				var kk = 0;
				for(var i = 0; i < aa.length; i++) {
					if(aa[i] == '') {
						aa.splice(i, 1)
					}
				}
				for(var i = 0; i < aa.length; i++) {
					aa[i] = Number(aa[i]);
					kk += aa[i];
				}
				t1 = all2 + kk;
				$('.t-money1').html('¥' + (all2 + kk));
				$('.t-allmoney').html('¥' + (t1 + t2));
			};

			$scope.uufun1 = function(index) {
				var gg = 0;
				var c = Number($('.numinp1').eq(index).val());
				var pr2 = $('.price2').eq(index).text();
				pr2 = pr2.split("¥")[1];
				pr2 = Number(pr2);
				c++;
				$('.numinp1').eq(index).val(c);
				var all2 = c * pr2;
				$('.onemoney1').eq(index).html('¥' + all2);

				var aa = $('.onemoney1').eq(index).parent().siblings().children('.onemoney1').text();
				aa = aa.split("¥");
				var kk = 0;
				for(var i = 0; i < aa.length; i++) {
					if(aa[i] == '') {
						aa.splice(i, 1)
					}
				}
				for(var i = 0; i < aa.length; i++) {
					aa[i] = Number(aa[i]);
					kk += aa[i];
				}
				t2 = all2 + kk;
				$('.t-money2').html('¥' + (all2 + kk));
				$('.t-allmoney').html('¥' + (t1 + t2));
			};
			$scope.colorfun = function() {
				window.location = 't-shoping2.html';
			}
		});

		app.controller('navctrl', function($scope) {
			$('.pleaselogin').html(localStorage.getItem("name"));
			$('.t-tui').html('退出');
			//我的订单
			$('.ding1').click(function(){
//				if (bubu) {
					window.location='personalcenter.html#/buy';
//				}else{
//					window.location='t-loadimg.html';
//				};
				
			});
			//我的消息
			$('.ding2').click(function(){
//				if (bubu) {
					window.location='personalcenter.html#/msg';
//				}else{
//					window.location='t-loadimg.html';
//				};
				
			});	
			//我的商家
			$('.ding3').click(function(){
//				if (bubu) {
					window.location='personalcenter.html#/store';
//				}else{
//					window.location='t-loadimg.html';
//				};
				
			});

			$('.t-tui').click(function() {
				if(bubu) {
					$('.pleaselogin').html('');
					$(this).html('请登录');
					bubu = false;

				} else {
					$(this).html('退出');
					window.location = 't-loadimg.html';
					localStorage.clear()
					bubu = true;
				}
			})
		});
		$('.logo-out div img').click(function(){
			window.location.href='index.html';
		})
	</script>

</html>